//
//  NetworkMessage.h
//  Networking
//
//	NetworkMessage class
//	data is defined by message type, see wiki
//  uses NSCoding for NSKeyedArchiver compatibility
//
//  Created by Christoph Eßer on 11/29/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum{
    kStringMessage, //0
    kConnectedMessage, //1
    kReconnectMessage, //2
    kDisconnectMessage, //3
    kQueryMessage, //4
    kStatus, //5
    kUserlistMessage, //6
    kMessageWithTarget, //7
    kMessageWithSender, //8
    //from here on: Messages we defined in the wiki
    //Organizatorial Messages
    kLoginMessage, //9
    kLoginReplyMessage, //10
    kLogoutMessage, //11
    kLogoutReplyMessage, //12 
    //Update Messages
    kLocationMessage, //13
    kKeyframeRHMessage, //14
    kKeyframeOpMessage, //15
    //Interaction Messages
    kAllowCatchMessage, //16
    kDisallowCatchMessage, //17
    kCatchMessage, //18
    kStopCatchMessage, //19
    kCatchStartMessage, //20
    kBeingCaughtMessage, //21
    kFreeMessage, //22
    kCatchEndMessage, //23
    kCaughtMessage, //24
    kAssignCPMessage, //25
	kAssignRNMessage, //26
    kAssignNotifyMessage, //27
    kAllowBringHomeMessage, //28
    kDisallowBringHomeMessage, //29
    kBringHomeMessage, //30
    kBringHomeOKMessage //31
}MessageType;


@interface NetworkMessage : NSObject <NSCoding> {
@private
    MessageType type;
	u_int32_t messageID;
	NSObject <NSCoding> *data;
}

@property (readonly) MessageType type;
@property (readonly) u_int32_t messageID;
@property (readonly) NSObject<NSCoding>* data;

-(id)initWithType: (MessageType) aType data:(NSObject<NSCoding>*) aData;
-(id)initWithString:(NSString*)str;
-(id)initWithStatus:(NSString*)status;
-(id)initWithConnected:(NSString*)connID;
-(id)initWithReconnect:(NSString*)connID;
-(id)initWithDisconnect;

-(id)initWithType: (MessageType) aType msgId: (u_int32_t) msgId data:(NSObject<NSCoding>*) aData __attribute__((deprecated));
-(id)initWithUserlist:(NSMutableDictionary *)users __attribute__((deprecated));
-(id)initWithTarget:(NSObject<NSCoding>*) aData withTarget:(NSString *)clientID __attribute__((deprecated));
-(id)initWithSender:(NSObject<NSCoding>*) aData withSender:(NSString *)clientID __attribute__((deprecated));
-(id)initWithQuery __attribute__((deprecated));

-(NSString*)stringMessage;

@end
